package com.wjjm.spoonselling.dao;

import com.wjjm.spoonselling.pojo.Merchant;
import org.apache.ibatis.annotations.*;

@Mapper
public interface MerchantDao {

    /**
     * 根据商家名称和密码，查询商家，实现登录
     * @return
     */
    @Select("select * from merchant where name=#{name} and password=#{password}")
    Merchant queryMerchantByNameAndPwd(Merchant merchant);

    /**
     * 根据商家名称进行查找，若存在，则不允许注册
     * @param name
     * @return
     */
    @Select("select * from merchant where name=#{name}")
    Merchant queryMerchantByName(@Param("name") String name);

    /**
     * 注册，插入一条记录
     * @param merchant
     */
    @Insert("insert into merchant values(#{merchantId},#{name},#{password},#{phone},#{address})")
    void register(Merchant merchant);

    @Update("update merchant set name=#{name},password=#{password},phone=#{phone},address=#{address} where merchantId=#{merchantId}")
    int update(Merchant merchant);
}
